using System;
using System.Collections.Generic;

namespace ActiveDirectoryUtilities.ReplDiag
{
	public class Sites : IEnumerable<SiteNCInfo>
	{
		private List<SiteNCInfo> _listOfSiteData = new List<SiteNCInfo>();

		public bool Contains(string siteName, string namingContext)
		{
			foreach (SiteNCInfo sni in _listOfSiteData)
			{
				if ((string.Compare(siteName, sni.SiteName, true) == 0)
					&& (string.Compare(namingContext, sni.NamingContext, true) == 0))
				{
					return true;
				}
			}
			return false;
		}

		public SiteNCInfo this[string siteName, string namingContext]
		{
			get
			{
				foreach (SiteNCInfo sni in _listOfSiteData)
				{
					if ((string.Compare(siteName, sni.SiteName, true) == 0)
						&& (string.Compare(namingContext, sni.NamingContext, true) == 0))
					{
						return sni;
					}
				}

				return null;
			}
		}

		public void Add(string siteName, string namingContext)
		{
			_listOfSiteData.Add(new SiteNCInfo(siteName, namingContext));
		}

		#region IEnumerable<SiteNCInfo> Members

		public IEnumerator<SiteNCInfo> GetEnumerator()
		{
			return _listOfSiteData.GetEnumerator();
		}

		#endregion

		#region IEnumerable Members

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return _listOfSiteData.GetEnumerator();
		}

		#endregion
	}

	public class SiteNCInfo
	{
		private string _siteName;
		private string _namingContext;
		private bool _hasAtLeastOneWritableInstance, _hasInbound, _hasOutbound;
		private List<DomainControllerReplicationInfo> _dcris = new List<DomainControllerReplicationInfo>();
		private int _numberOfInstances;

		public string SiteName
		{
			get { return _siteName; }
			set { _siteName = value; }
		}

		public string NamingContext
		{
			get { return _namingContext; }
			set { _namingContext = value; }
		}

		public bool HasAWritableInstance
		{
			get { return _hasAtLeastOneWritableInstance; }
			set { _hasAtLeastOneWritableInstance = value; }
		}

		public bool HasInbound
		{
			get { return _hasInbound; }
			set { _hasInbound = value; }
		}

		public bool HasOutbound
		{
			get { return _hasOutbound; }
			set { _hasOutbound = value; }
		}

		public int NumberOfInstances
		{
			get { return _numberOfInstances; }
			set { _numberOfInstances = value; }
		}

		public SiteNCInfo(string siteName, string namingContext)
		{
			_siteName = siteName;
			_namingContext = namingContext;
		}
	}
}
